package com.zlw.rabbitmq.api.consumer;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DefaultConsumer;
import com.rabbitmq.client.Envelope;
import org.springframework.beans.factory.parsing.SourceExtractor;

import java.io.IOException;

/**
 * @author Zhaoluowei
 * @version 1.0
 * @date 2019/12/24 0:29
 */
public class MyChannel extends DefaultConsumer {
    /**
     * Constructs a new instance and records its association to the passed-in channel.
     *
     * @param channel the channel to which this consumer is attached
     */
    public MyChannel(Channel channel) {
        super(channel);
    }

    @Override
    public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
        //super.handleDelivery(consumerTag, envelope, properties, body);
        System.err.println("--------------------------------------");
        System.out.println("consumerTag : " + consumerTag);
        System.out.println("envelope : " + envelope.toString());
        System.out.println("properties : " + properties);
        System.out.println("body : " + new String(body));

    }
}
